const express = require('express');
const router = express.Router();

router.get('/forCurrentUser', (req, res) => { 
    const content = [];
    for(let i = 0; i < 40; i++)
        content.push({
            id: `2019${i}`,
            dealerCode: `dealerCode${i}`,
            dealerName: `总代名称${i}`,
            code: `code${i}`,
            saleShipmentCode: 'SaleShipmentCode',
            vin: `vin${i}`,
            productCategoryCode: 'productCategoryCode',
            PdiCheckResult: 1,
            checkTime: '2020-03-02T07:49:31.607Z',
            checkMan: 'checkMan',
            status: 1,
            remark: 'remark',
            rowVersion: 'rowVersion',
            options: [
                'update',
                'abandon',
                'approve',
            ]
        });
    res.json({
        message: '',
        payload: {
            content,
            totalElements: 40,
        }
    });
});
router.get('/:id', async(req, res, next) => {
    res.json({
        message: '',
        payload: {
            id: '001',
            code: 'code001',
            branchId: 'branchId001',
            branchCode: 'branchCode001',
            branchName: 'branchName',
            brandId: 'brandId001',
            brandCode: 'brandCode001',
            brandName: 'brandName',
            dealerId: 'dealerId001',
            dealerCode: 'dealerCode001',
            dealerName: 'dealerName001',
            vin: 'vin',
            productCategoryCode: 'productCategoryCode',
            PdiCheckResult: 1,
            checkMan: 'checkMan',
            checkTime: '2020-03-18T07:20:25.684Z',
            remark: 'remark',
            status: 1,
            creatorName: 'creatorName',
            createTime: '2020-03-02T08:40:53.602Z',
            abandonerName: 'abandonerName',
            abandonTime: '2020-03-02T08:40:53.602Z',
            saleShipmentId: '001',
            saleShipmentCode: 'saleShipmentCode',
            attachments: [
                {
                    fileId: '001',
                    fileName: 'fileName001'
                }
            ],
            rowVersion: 'string',
            options: ['update', 'abandon', 'approve'],
        }
    });
});

router.post('/', async(req, res, next) => {
    res.json({
        message: '新增成功'
    });
});

router.put('/:id', async(req, res, next) => {
    res.json({
        message: '编辑成功'
    });
});

router.put('/:id/abandon', (req, res) => {
    res.json(
        {
            message: '作废成功'
        }
    );
});

router.put('/:id/approve', (req, res) => {
    res.json(
        {
            message: '审核成功'
        }
    );
});

router.get('/forCurrentUser/export', async(req, res, next) => {
    res.json({
        message: '导出成功',
        payload: 'Mock导出'
    });
});

router.post('/import', (req, res) => {
    res.json({
        message: 'success',
        payload: '导入成功'
    });
});

module.exports = router;
